package com.iwdnb.gkgz.job;

import java.util.Date;

import cn.hutool.core.date.DateUtil;
import com.iwdnb.bmnf.common.utils.BooleanUtils;
import com.iwdnb.gkgz.application.service.TulongdaoService;
import com.iwdnb.gkgz.common.utils.DateUtils;
import com.iwdnb.job.annotation.Job;
import com.iwdnb.job.handler.BaseJobHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import static com.iwdnb.gkgz.common.utils.WorkTimeUtils.isWorkingTime;

/**
 * 股票屠龙刀信号校验任务
 */
@Slf4j
@Job(cron = "30 * 9,10,11,13,14,15 * * ?")
public class StockTulongdaoSignalJob extends BaseJobHandler {

    @Autowired
    private TulongdaoService tulongdaoService;

    @Override
    public boolean doProcess(String parameter) {
        if (!isWorkingTime()) {
            return true;
        }
        //9:24之前不处理情绪
        Date now = new Date();
        String date = DateUtil.formatDate(now);
        String beginDateTime = date + " 09:24:00";
        if (DateUtils.before(now, DateUtil.parseDateTime(beginDateTime))) {
            return true;
        }
        tulongdaoService.checkSignal(new Date(), null, BooleanUtils.FALSE, true, true, false);
        return true;
    }
}
